package com.example.orderservice.controller;

import com.example.nacosdemo.dto.ChangeOrderDTO;
import com.example.nacosdemo.dto.ReduceDTO;
import com.example.nacosdemo.exception.ServiceException;
import com.example.orderservice.service.OrderService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/order/")
@AllArgsConstructor
@Slf4j
public class OrderController {


    private final OrderService orderService;

    @PostMapping("create_order")
    public String createOrder(@RequestBody ReduceDTO dto){
        orderService.createOrder(dto);
        return "下单成功";
    }

    @PostMapping("change_order")
    public void changeOrder(@RequestBody ChangeOrderDTO dto) throws ServiceException {
        orderService.changeOrder(dto);
    }
}
